package com.lichuandi.controller;

import com.lichuandi.service.UsersService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController // 测试AOP使用
public class TestAopController {
    private final UsersService usersService;

    /**
     * 使用构造器的方式注入 usersService
     * @param usersService --
     */
    public TestAopController(UsersService usersService) {
        this.usersService = usersService;
    }

    @GetMapping("/test")
    public String test() {
        return usersService.getUserById(1L);
    }

    @GetMapping("/error")
    public void error() {
        usersService.throwException();
    }
}